/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
int* occurrencesOfElement(int* nums, int numsSize, int* queries, int queriesSize, int x, int* returnSize)
{
    int * coust=(int *)malloc(numsSize*sizeof(int));
    int len=0;
    for(int i=0;i<numsSize;i++)
    {
        if(nums[i]==x)
        coust[len++]=i;  //找出所有x的下标并将下标保存在coust中
    }
    int *result =(int *)malloc(queriesSize*sizeof(int));//创建返回数组
    *returnSize = queriesSize;
    for(int i=0 ; i<queriesSize;++i)
    {
        result[i] = queries[i] <= len ? coust[queries[i] - 1] : -1;
    }

    free(coust);
    return result;
    
}